import javax.swing.*;
import java.awt.*;

/**
 * @classname 主界面绘制
 * @Author 姬如千泷
 * @Date 2021/4/26  19:29
 * @Version 1.0
 */
public class MyFrame extends JFrame{
    MyFrame myFrame;
    public MyTown bg_panel;//背景
    public MyCharacter ct_label;//角色
    public MyFrame() {
        init();
        bg_panel = new MyTown(myFrame,0);
        ct_label = new MyCharacter(myFrame, bg_panel);
        bg_panel.ct_label=ct_label;
        MyListener listener = new MyListener(ct_label);
        listener.windowsListen(this);
        bg_panel.addKeyListener(listener);
        this.addKeyListener(listener);
        this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(DateCenter.mouse, new Point(16, 16), "mycursor"));
        this.add(bg_panel);
        this.setVisible(true);
    }
    public MyFrame(int x,int y,int z) {
        init();
        bg_panel = new MyTown(myFrame,z);
        ct_label = new MyCharacter(x,y,z,myFrame, bg_panel);
        bg_panel.ct_label=ct_label;
        MyListener listener = new MyListener(ct_label);
        listener.windowsListen(this);
        bg_panel.addKeyListener(listener);
        this.addKeyListener(listener);
        this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(DateCenter.mouse, new Point(16, 16), "mycursor"));
        this.add(bg_panel);
        this.setVisible(true);
    }
    public void init(){
        this.setBounds(400,100,1200,900);
        this.setResizable(false);
        this.setLayout(null);
        this.setTitle("Linの大冒险");
        myFrame =this;
       }
}


